﻿<%@ Page Title="" Language="C#" MasterPageFile="~/web/common/admin_common.Master" AutoEventWireup="true" CodeBehind="edit.aspx.cs" Inherits="shop.web.view_admin.user.edit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>编辑用户</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="fly-panel" pad20 style="padding-top: 5px;">
        <div class="layui-form layui-form-pane">
            <div class="layui-tab layui-tab-brief" lay-filter="user">
                <ul class="layui-tab-title">
                    <li class="layui-this">编辑用户</li>
                </ul>
                <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">

                    <div class="layui-tab-item layui-show">
                        <form method="post" action="/handler/UserHandler.ashx">
                            <input type="hidden" name="method" value="update" />
                            <input type="hidden" name="id" value="<%=user.Id %>" />
                            <div class="layui-form-item">
                                <label for="L_name" class="layui-form-label">
                                    姓名</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="L_name" name="name" required lay-verify="required" placeholder="用户名称"
                                        autocomplete="off" class="layui-input" value="<%=user.Name %>">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="L_password" class="layui-form-label">
                                    密码</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="L_password" name="password" required lay-verify="required" placeholder="用户价格"
                                        autocomplete="off" class="layui-input" value="<%=user.Password %>">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="L_rePassword" class="layui-form-label">
                                    确认密码：</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="L_rePassword" name="rePassword" required lay-verify="required" placeholder="用户价格"
                                        autocomplete="off" class="layui-input" value="<%=user.Password %>">
                                </div>
                            </div>
                            <div class="layui-inline  layui-form-item">
                                <label class="layui-form-label">
                                    等级</label>
                                <div class="layui-input-block rankId">
                                    <select lay-verify="required" name="rankId">
                                        <option>用户等级</option>
                                        <%foreach (var role in roleList)
                                            {
                                                if (user.Rank == role.Id)
                                                {
                                        %>
                                        <option value="<%=role.Id %> " selected><%=role.RoleName %></option>
                                        <%
                                            }
                                            else
                                           {
                                        %>
                                        <option value="<%=role.Id %> "><%=role.RoleName %></option>
                                        <%
                                                }
                                            } %>
                                    </select>
                                </div>
                            </div>

                        </form>

                        <div class="layui-form-item">
                            <button class="layui-btn update" type="button">
                                立即更新</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="../../resource/wangEditor/wangEditor.min.js"></script>

    <script>


        layui.use('form', function () {
            var form = layui.form;
        })




        $(".update").click(function () {
            $.ajax({
                url: $('form').attr('action'),
                type: "post",
                data: $("form").serialize(),
                success: function (data) {
                    console.log($("form").serialize())

                    console.log(data)
                    var obj = JSON.parse(data);
                    console.log(data)
                    if (obj.ErrorCode === 0) {
                        //成功
                        layer.msg(obj.Message, { icon: 6 }, function () {
                            window.location.href = "/web/view_admin/user/List.aspx";
                        });

                    } else {
                        layer.msg(obj.Message, { icon: 2 })
                    }
                }
            })
        })

    </script>
</asp:Content>

